﻿using Architecture.Api.Application.Commands.ImmuneInFormationCommand;
using Architecture.Domain.Services.Interface;
using Architecture.Domain.TraceabilityManage;
using AutoMapper;
using MediatR;

namespace Architecture.Api.Application.CommandHandlers.ImmuneInFormationHandler
{
    public class ImmuneInFormationCreateCommandHandler : IRequestHandler<ImmuneInFormationCreateCommand, int>
    {
        private readonly ICultureService _cultureService;
        private readonly IMapper _mapper;

        public ImmuneInFormationCreateCommandHandler(ICultureService cultureService,
                                                     IMapper mapper)
        {
            _cultureService = cultureService;
            _mapper = mapper;
        }

        public async Task<int> Handle(ImmuneInFormationCreateCommand request, CancellationToken cancellationToken)
        {
            ImmuneInFormation immune = _mapper.Map<ImmuneInFormation>(request);
            return await _cultureService.AddImmuneInFormation(immune);
        }
    }
}
